<template>
	<div class="index" style="background: rgb(246, 248, 251);" >
    <van-nav-bar title="设置" left-arrow  @click-left="onClickLeft" />
    <div style="padding:0.3rem; ">
      <div class="flexcc" style="height: 90vh;" v-if="!info">
        <img src="../../../static/img/jiameng.png" style="width: 4.5rem;" />
      </div>

      <div style="position: fixed; bottom: 0.5rem; left: 0.5rem; width: 6.6rem;">
        <div @click="show2 = true" class="flexcc" style="background: #fff;  height: 0.9rem; box-shadow: 0px 0.1rem 0.2rem 0px rgba(0, 90, 255, 0.1); border-radius: 0.45rem; font-size: 0.31rem; color: rgb(2, 12, 29);">
          退出登录
        </div>
      </div>
    </div>

    <van-popup v-model="show2" round position="center" style="width: 5rem;">
      <div style="padding: 0.8rem 0.3rem 0.5rem;">
        <div style="font-size: 0.28rem; text-align: center;">您确定要退出当前账户么？</div>
        <div class="flexbc" style="margin-top: 0.7rem;">
          <div @click="show2 = false" class="flexcc" style="background: rgb(204, 204, 204); width: 2rem;  height: 0.7rem; box-shadow: 0px 0.1rem 0.2rem 0px rgba(0, 90, 255, 0.1); border-radius: 0.35rem; font-size: 0.31rem; color: rgb(2, 12, 29);">
            取消
          </div>
          <div @click="tuichu()" class="flexcc" style="background: rgb(0, 90, 255);  width: 2rem;  height: 0.7rem; box-shadow: 0px 0.1rem 0.2rem 0px rgba(0, 90, 255, 0.1); border-radius: 0.35rem; font-size: 0.31rem; color: #fff;">
            确认
          </div>
        </div>
      </div>

    </van-popup>
	</div>
</template>

<script>
  var h = document.documentElement.clientWidth / 7.5 + 'px';
  document.documentElement.style.fontSize = h;
	export default {
		name: 'query',
		data() {
			return {
        show:false,
        show2:false,
        all:{
          name:"",
          password:"",
          mobile:"",
          sms_code:"",
          shop_id:this.$route.query.shop_id,
          micro_stores_name:""
        },
        all2:{
          name:"",
          password:""
        },
        info:"",
        yzmnum:60,
        yzm:'获取验证码',
        yzmuse:true,
			}
		},
		created() {
      this.getinfo()
		},
		mounted() {
      document.title = "加盟站点"
		},
		methods: {
      tuichu:function(){
        axios.post(`/agent/auth/logout`)
        	.then(response=> {
        		if (response.data.msg.code == 0) {
              this.$router.push('/index'+location.search)
        		}else{
              vant.Toast(response.data.msg.info);
            }
        	})
      },
      denglu:function(){
        axios.post(`/api/login`, this.all2)
        	.then(response=> {
        		if (response.data.msg.code == 0) {
              vant.Toast("登陆成功");
              if(response.data.data.is_owner == 1){
                setTimeout(()=>{
                  location.href = location.origin + '/hou/shangpinguanli/zaishoushangpin'
                },500)
              }else{
                setTimeout(()=>{
                  location.href = location.origin + '/h5/geren'+location.search
                },500)
              }
        		}else{
              vant.Toast(response.data.msg.info);
            }
        	})

      },
      //获取验证码
      getcode: function() {
        var that = this;
        if(that.yzmuse){
          if (this.all.mobile.length != 11) {
          	vant.Toast("请输入正确手机号");
          	return;
          }
          that.yzmuse = false
          that.yzmnum = 60;
          that.timer = setInterval(function() {
          	if (that.yzmnum == 0) {
          		clearInterval(that.timer);
          		that.yzm = '获取验证码';
          		that.yzmuse = true
          	} else {
          		that.yzmuse = false
          		that.yzm = that.yzmnum + '秒重新获取';
          		that.yzmnum = that.yzmnum - 1;
          	}
          }, 1000);

          axios.post(`/api/register/code/send`, {mobile:this.all.mobile,type:''})
          	.then(function(response) {
          		if (response.data.msg.code == 0) {
          			vant.Toast("验证码已发送");
          		}else{
                vant.Toast("发送失败");
              }
          	})
        }
      },
      chuangjian:function(){
        axios.post('/api/mstore/join',this.all).then((response)=>{
        	if (response.data.msg.code == 0) {
           vant.Toast("店铺创建成功");
           this.show = false
           this.$router.push('/geren'+location.search)

        	} else {
            vant.Toast(response.data.msg.info);
        	}
        })
      },
      onClickLeft:function(){
        this.$router.back(-1)
      },
      getinfo:function(){
        axios.get('/api/mstore/inv/des').then((response)=>{
        	if (response.data.msg.code == 0) {
           this.info = response.data.data.reseller_inv_des
        	} else {
            vant.Toast(response.data.msg.info);
        	}
        })
      }
		}
	}
</script>


<style scoped lang="less">
  .index{
    .van-cell{ background: rgb(246, 248, 251);}
  }
</style>
